﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;

namespace TheBullysStore.Models.ModuloAdministracion.TipoGasto
{
    public class TipoGastoDAO
    {
        public List<TipoGastoBean> ListarTipoGastos(TipoGastoBean gasto)
        {
            try
            {
                List<TipoGastoBean> listaGasto = new List<TipoGastoBean>();
                String cadenaConfiguracion = ConfigurationManager.ConnectionStrings["TheBullysStore"].ConnectionString;
                SqlConnection sqlCon = new SqlConnection(cadenaConfiguracion);
                sqlCon.Open();
                string commandString = "select * from tipo_gasto";
                SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon);

                SqlDataReader dataReader = sqlCmd.ExecuteReader();

                while (dataReader.Read())
                {
                    TipoGastoBean tipoGasto = new TipoGastoBean();
                    tipoGasto.Descripcion = (string)dataReader[0];
                    tipoGasto.TipoGasto = (int)dataReader[1];
                    listaGasto.Add(tipoGasto);
                }
                sqlCon.Close();
                return listaGasto;
            }
            catch
            {
                return null;
            }
        }
    }
}